Class WSClient

java.lang.Object
com.seclore.fs.ws.client.WSClient

public class WSClient extends Object
This class provides methods to deal with the file operations like
  • protecting a file
  • unprotecting a file
  • validating that the file is protected
  • get the protected file header
  • generate the file details for protect
Before any of the method is called, the Client must be initialized by calling the initialize method, else the Client not initialize error will be thrown.
  • Method Details

    • newInstance

      public static WSClient newInstance(WSClientConfig pWSClientConfig) throws WSClientException
      Calls the private constructor of WSClient.
      Parameters:
      pWSClientConfig - - WSClient Configuration
      Returns:
      WSClient object
      Throws:
      WSClientException
    • getFileHeader

      public String getFileHeader(String pProtectedFile) throws WSClientException
      This method reads the given file and return the header if it is protected else throws exception.
      Parameters:
      pProtectedFile - The name of the file along with the complete path of the file whose header is requested.
      Returns:
      The protected file header.
      Throws:
      WSClientException - The WSClientException thrown by the method.
      IOException - The IOException thrown by the method.
    • getFileHeader

      public String getFileHeader(com.seclore.io.SeekableStream pInputStream) throws WSClientException
      Throws:
      WSClientException
    • getHtmlWrappedFileHeader

      public String getHtmlWrappedFileHeader(String pHtmlWrappedFile) throws WSClientException
      This method reads the given html wrapped file and returns the header if it is protected else throws exception.
      Parameters:
      pHtmlWrappedFile - The name of the file along with the complete path of the file whose header is requested.
      Returns:
      The protected file header.
      Throws:
      WSClientException - The WSClientException thrown by the method.
      IOException - The IOException thrown by the method.
    • getHtmlWrappedFileHeader

      public String getHtmlWrappedFileHeader(com.seclore.io.SeekableStream pInputStream) throws WSClientException
      Throws:
      WSClientException
    • getFileId

      public String getFileId(String pProtectedFile) throws WSClientException
      This method reads the given file and return the File Id if it is protected else throws exception.
      Parameters:
      pProtectedFile - The name of the file along with the complete path of the file whose header is requested.
      Returns:
      The protected file Id.
      Throws:
      WSClientException - The WSClientException thrown by the method.
      IOException - The IOException thrown by the method.
    • getHtmlWrappedFileId

      public String getHtmlWrappedFileId(String pHtmlWrappedFile) throws WSClientException
      This method reads the given html wrapped file and returns the File Id if it is protected else throws exception.
      Parameters:
      pHtmlWrappedFile - The name of the file along with the complete path of the file whose header is requested.
      Returns:
      The seclore file Id.
      Throws:
      WSClientException - The WSClientException thrown by the method.
      IOException - The IOException thrown by the method.
    • unprotect

      public com.seclore.fs.helper.core.UnprotectedFile unprotect(String pProtectedFile, String pUnProtectResponseXML, boolean pIsSecureMessage, byte[] pRequestKey, CryptoHandler pCryptoHandler) throws WSClientException
      This method unprotect the requested file, if it is already protected, else will throw error.
      Parameters:
      pProtectedFile - Name along with the complete path of protected file.
      pUnProtectResponseXML - Unprotect API response returned by the Policy Server.
      pIsSecureMessage - Is the Response XML is in secure communication format.
      pRequestKey - Request Key to decrypt the Response XML if the xml is in secure communication format.
      pCryptoHandler - CryptoHandler to decrypt the Response XML if the xml is in secure communication format.
      Throws:
      WSClientException - The WSClientException thrown by the method in case any IO error occurs.
    • getFileDetailsXML

      public String getFileDetailsXML(String pFile, String pDisplayFile) throws WSClientException
      This method returns the file details XML that can be used to call the protect API to Policy Server.
      Parameters:
      pFile - The name of the file along with the complete path of the file to be protected. File should exist on the disk.
      pDisplayFile - Display name of the file.
      File need not exist on the disk. This value will be used for protect activity.
      This value should contain the complete file path. if only filename is passed, then we use the same value for path and file name.
      Returns:
      The File details XML
      Throws:
      WSClientException - The WSClientException thrown by the method.
      IOException - The IOException thrown by the method.
    • getFileDetailsXML

      public String getFileDetailsXML(String pFile) throws WSClientException
      This method returns the file details XML that can be used to call the protect API to Policy Server.
      Parameters:
      pFile - The name of the file along with the complete path of the file to be protected.
      Returns:
      The File details XML
      Throws:
      WSClientException - The WSClientException thrown by the method.
      IOException - The IOException thrown by the method.
    • getVersion

      public static String getVersion()
      This method returns the version information.
    • protect

      public void protect(String pOriginalFileName, String pFileInfoXML, String pProtectionResponseXML) throws WSClientException
      This method protects the requested File.
      Parameters:
      pOriginalFileName - Name along with the complete path of the file to be protected.
      pFileInfoXML - XML which is used to call the protect API to Policy Server.
      pProtectionResponseXML - Response XML of the protect request API from the Policy Server.
      Throws:
      WSClientException - The WSClientException thrown by the method in case of any IO error.
    • createSMail

      public com.seclore.fs.ws.client.mail.utilities.SMailDetails createSMail(IMailInput pMailInput, String pFolderPath) throws WSClientException
      This method creates SMail File in provided folder path using Mail Input.
      Parameters:
      pMailInput - MailInput class contains all the information required for creating smail file
      pFolderPath - path in which SMail file is to be created
      Returns:
      Throws:
      WSClientException
      IOException
    • protectAndGetFileName

      public String protectAndGetFileName(String pOriginalFileName, String pFileInfoXML, String pProtectionResponseXML) throws WSClientException
      This method protects the requested File.
      Parameters:
      pOriginalFileName - Name along with the complete path of the file to be protected.
      pFileInfoXML - XML which is used to call the protect API to Policy Server.
      pProtectionResponseXML - Response XML of the protect request API from the Policy Server.
      Returns:
      Returns the Unique File Identifier.
      Throws:
      WSClientException - The WSClientException thrown by the method in case of any IO error.
    • protectAndGetFileName

      public String protectAndGetFileName(String pOriginalFileName, String pFileInfoXML, String pProtectionResponseXML, boolean pIsSecureMessage, byte[] pRequestKey, CryptoHandler pCryptoHandler) throws WSClientException
      Throws:
      WSClientException
    • protectAndGetProtectedFile

      public com.seclore.fs.helper.core.ProtectedFile protectAndGetProtectedFile(String pOriginalFileName, String pFileInfoXML, String pProtectionResponseXML, boolean pIsSecureMessage, byte[] pRequestKey, CryptoHandler pCryptoHandler) throws WSClientException
      This method protects the requested File.
      Parameters:
      pOriginalFileName - Name along with the complete path of the file to be protected.
      pFileInfoXML - XML which is used to call the protect API to Policy Server.
      pProtectionResponseXML - Response XML of the protect request API from the Policy Server.
      pIsSecureMessage - Is the Response XML is in secure communication format.
      pRequestKey - Request Key to decrypt the Response XML if the xml is in secure communication format.
      pCryptoHandler - CryptoHandler to decrypt the Response XML if the xml is in secure communication format.
      Returns:
      Returns the Unique File Identifier.
      Throws:
      WSClientException - The WSClientException thrown by the method in case of any IO error.
    • isProtectedFile

      public boolean isProtectedFile(String pFilePath) throws WSClientException
      This method returns whether a file is FileSecure protected or not. It takes file path as input parameter.
      Parameters:
      pFilePath - This string contains the path of the file which is to be checked for FileSecure protection.
      Returns:
      true, if the file is protected else false.
      Throws:
      WSClientException
    • isProtectedFile

      public boolean isProtectedFile(byte[] pFileData) throws WSClientException
      This method returns whether a passed bytes are of FileSecure protected file or not.
      Parameters:
      pFileData - This should be bytes of the file which is to be checked for FileSecure protection. Only first 1 MB of the file data needs to be passed here. If the file size is less than 1 MB then the entire file data should be passed.
      Returns:
      true, if the bytes are of FileSecure protected file else false.
      Throws:
      WSClientException
    • isAdvancedProtectionSupportedFile

      public boolean isAdvancedProtectionSupportedFile(String pFilePath) throws WSClientException
      This method returns whether a file is of advance protection FileSecure supported extension or not.
      Parameters:
      pFilePath -
      Returns:
      Throws:
      WSClientException
    • isSupportedFile

      public boolean isSupportedFile(String pFilePath) throws WSClientException
      This method returns whether a file is of FileSecure supported extension or not.
      Parameters:
      pFilePath - It contains the path of the file for which we have to determine if it is of FileSecure supported extension or not. This may be just the name of the file also.
      Returns:
      true, if the file is FileSecure supported extension.
      Throws:
      WSClientException
    • isBasicProtectionSupportedFile

      public boolean isBasicProtectionSupportedFile(String filePath) throws WSClientException
      This method returns whether a file is of basic protection FileSecure supported extension or not.
      Parameters:
      filePath - - It contains the path of the file for which we have to determine if it is of FileSecure supported extension or not. This may be just the name of the file also.
      Returns:
      true, if the file is FileSecure supported extension.
      Throws:
      WSClientException
    • wrap

      public String wrap(com.seclore.fs.helper.core.WrapperInputDetails pWrapperDetailsBean) throws WSClientException
      This method wrap (convert) protected file into HTML file and return absolute file location of wrapped file. Wrapped HTML file will be created in same directory of pProtectedFilePath and name of the HTML file will be same as protected filename followed by ".html" suffix. Example: If the protected file is 'D:/SampleFile.pdf' then wrapped HTML file will be 'D:/SampleFile.pdf.html'.
      This method also takes custom data to be written in wrapped file, also encode (escape) the data for HTML before writing into file so caller should just pass the data.
      Note: This method does not delete the protected file after wrapping. Caller should delete both protected file and HTML wrapped file after uses.
      Parameters:
      pWrapperDetailsBean - This bean is a wrapper. The data from this bean will be used for wrapping.
      Returns:
      Absolute path of target HTML wrapped file.
      Throws:
      WSClientException - - The WSClientException thrown by the method in case of any IO error.
    • unwrap

      public com.seclore.fs.helper.core.UnwrapOutputDetails unwrap(String pHtmlWrappedFilePath) throws WSClientException
      This method will unwrap the protected wrapped file at pSourceFilePath and return the absolute path of unwrapped file. Unwrapped file would be created in same directory of the pSourceFilePath.
      Unwrapped file name will be created with same name as source file name without '.html' extension. If original extension is not present in source file name then the original extension will be appended.
      Example:
      1. If wrapped file name is "SampleFile.pdf.html" and original file is "SampleFile.docx", then unwrapped file name would be SampleFile.pdf.docx
      2. If wrapped file name is "SampleFile.pdf.html" and original file is "SampleFile.pdf", then unwrapped file name would be SampleFile.pdf
      Note: This method does not delete the html file after un-wrapping. Caller should delete both protected file and HTML wrapped file after uses. NOTE : There should not be any file in the directory of pHtmlWrappedFilePath with SAME NAME irrespective of the extension.
      Parameters:
      pHtmlWrappedFilePath - Absolute path of html file to be un-wrapped.
      Returns:
      Absolute path of unwrapped protected file.
      Throws:
      WSClientException - - The WSClientException thrown by the method in case of any IO error.
    • isHtmlWrapSupported

      public boolean isHtmlWrapSupported(String pFilePath) throws WSClientException
      This method returns whether a file is supported for HTMl wrap or not. It takes file path as input parameter.
      Parameters:
      pFilePath - This string contains the path of the file which is to be checked for HTML wrap.
      Returns:
      true, if the file is supported for HTMl wrap.
      Throws:
      WSClientException
    • isHtmlWrappedFile

      public boolean isHtmlWrappedFile(String pFilePath) throws WSClientException
      This method determines whether the given file is html wrapped or not.
      Parameters:
      pFilePath - : Absolute path of the file which is to be checked.
      Returns:
      True if the file is html wrapped or it returns false.
      Throws:
      WSClientException
    • isHtmlWrappedFile

      public boolean isHtmlWrappedFile(byte[] pFileData) throws WSClientException
      Throws:
      WSClientException
    • getCustomAttributesFromHTMLFile

      public String getCustomAttributesFromHTMLFile(String pFilePath) throws WSClientException
      This method returns the Custom Attributes from HTML file.
      Parameters:
      pFilePath - : Absolute path of the file which is to be checked.
      Returns:
      Custom Attributes as String. null if no custom attribute is present in the file.
      Throws:
      WSClientException
    • getHtmlCustomMetadata

      public String getHtmlCustomMetadata(String pFilePath) throws WSClientException
      This method returns the Custom HTML MetaData from HTML file.
      Parameters:
      pFilePath - : Absolute path of the file.
      Returns:
      Custom HTML MetaData as String. null if no custom HTML MetaData is present in the file.
      Throws:
      WSClientException
    • getLocaleFromHTMLFile

      public String getLocaleFromHTMLFile(String pFilePath) throws WSClientException
      This method returns the Locale of the HTML file.
      Parameters:
      pFilePath - : Absolute path of the file which is to be checked.
      Returns:
      Locale as String. null if no locale attribute is present in the file.
      Throws:
      WSClientException
    • getPsIdFromFile

      public String getPsIdFromFile(String pProtectedFile) throws WSClientException
      Throws:
      WSClientException
    • getSupportedHTMLWrapperVersions

      public com.seclore.fs.ws.client.wrapper.html.versions.InternalHtmlWrapperVersions getSupportedHTMLWrapperVersions() throws WSClientException
      This method returns HTML wrapper buffer and form data versions which is supported by wsclient.
      Returns:
      InternalHtmlWrapperVersions
      Throws:
      WSClientException
    • setExternalHtmlWrapperVersions

      public void setExternalHtmlWrapperVersions(Node pHtmlWrapperVersion) throws WSClientException
      Set HTML wrapper buffer and form data versions which is received in PS ping response.
      Parameters:
      pHtmlWrapperVersion -
      Throws:
      WSClientException